/**
 * 
 */
package com.smsclient.model;

import org.apache.commons.lang3.StringUtils;

/**
* 描述: [运营商 类型]</br>
* 初始作者: Magina<br/>
* 创建日期:14:30 2019/7/10<br/>
* 开始版本: 1.0.0<br/>
* =================================================<br/>
* 修改记录：<br/>
* 修改作者 日期 修改内容<br/>
* ================================================<br/>
* @param
* @return
*/
public enum IspType  {

    CT("中国电信","CT"),
    CM("中国移动","CM"),
    CU("中国联通","CU"),
    OTHER("未知运营商","OTHER");

    private String ispChzName;
    private String ispCode;
    private IspType( String ispChzName,String ispCode) {
        this.ispChzName = ispChzName;
        this.ispCode = ispCode;
    }

    public static String getCode(String name){
        for (IspType type : IspType.values()){
            if(StringUtils.equalsIgnoreCase(name,type.getIspChzName())){
                return type.getIspCode();
            }
        }
        return OTHER.getIspCode();
    }
    public static String getName(String code){
        for (IspType type : IspType.values()){
            if(StringUtils.equalsIgnoreCase(code,type.getIspCode())){
                return type.getIspChzName();
            }
        }
        return OTHER.getIspChzName();
    }


    public String getIspCode() {
        return ispCode;
    }

    public void setIspCode(String ispCode) {
        this.ispCode = ispCode;
    }

    public void setIspChzName(String ispChzName) {
        this.ispChzName = ispChzName;
    }

    public String getIspChzName() {
        return ispChzName;
    }
}


